﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main.Models
{

  public  class SalaryContext : DbContext
    {
        public DbSet<SalaryItem> SalaryItems { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder options)
          => options.UseSqlite("Data Source=Salary.db");

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SalaryItem>().Ignore(s => s.Month);
            modelBuilder.Entity<SalaryItem>().Property(s => s.Name).IsRequired();
            modelBuilder.Entity<SalaryItem>().Property(s => s.Value).IsRequired();
            modelBuilder.Entity<SalaryItem>().Property(s => s.MonthIndex).IsRequired();
        }
    }
}
